package com.example.yjhmatch.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.yjhmatch.mapper.MatchesMapper;
import com.example.yjhmatch.service.IMatchesService;
import com.mysql.jdbc.StringUtils;
import com.yc.yjh.entity.Matches;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 赛程表 服务实现类
 * </p>
 *
 * @author 廖老师
 * @since 2023-07-20
 */
@Service
public class MatchesServiceImpl extends ServiceImpl<MatchesMapper, Matches> implements IMatchesService {


    @Resource
    MatchesMapper matchesMapper;

    @Override
    public List<Matches> selectMatch(String mid, String tname, String time) {
        QueryWrapper<Matches> wrapper = new QueryWrapper<>();
        if (StringUtils.isNullOrEmpty(mid)){
            wrapper.eq("tournament_id",mid);
        }
        if (StringUtils.isNullOrEmpty(tname)){
            wrapper.like("home_team_name",tname)
                    .or().like("away_team_name",tname);
        }
        if (StringUtils.isNullOrEmpty(time)){
            wrapper.eq("time",time);
        }
       return matchesMapper.selectMatchsByWrapper(wrapper);
    }
}
